package com.spmsys.listener;

import com.spmsys.logUtil.LOGGER;
import jakarta.servlet.ServletContextEvent;
import jakarta.servlet.ServletContextListener;
import jakarta.servlet.annotation.WebListener;

@WebListener
public class ContextListener implements ServletContextListener {
    private Thread logThread = null;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        //开始记录日志
        logThread = LOGGER.start_record_log();
        logThread.start();
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        if (logThread != null) {
            //结束记录日志
            logThread.interrupt();
        }
    }
}
